// 這是個人中心的倉庫
import {makeAutoObservable} from "mobx";
import {getProfile,upTou,publice} from "@/services/index";
import {UProfile} from "@/utils/useref";


class UseRef{
    // 頭像的接口
    imgSrc:string="";
    // 默認的數據
    uulist:UProfile[]=[];
    // 彈框
    istan:boolean=false
    constructor(){
        makeAutoObservable(this);
    }
    // 獲取初始化的數據
    async getProfile(){ 
        let result=await getProfile();
        if(result.code){            
            this.imgSrc=result.data.avatar;
            this.uulist=result.data;
        }
    }
    //提交頭像
    async upTou(data:FormData){
            let result=await upTou(data);
            if(result.code===200){
                this.imgSrc=result.imgUrl;
            }            
    }
    //提交整體修改
    async publice(data:any){
        let res= await  publice(data);
        res.code===200?  this.istan=true:this.istan=false
    }

}

export default new UseRef

